 # -*- coding: UTF-8 -*-
import urllib
import requests
import os

def downImg(src, path):
	f = src.split('/')[-1].split('?')[0]
	#print(f)
	fpath = path + f
	print(fpath)
	if f.find('.') < 1:
		return
	if os.path.exists(fpath):
		return
	try:
		r = urllib.urlretrieve(src, path + f)
	except Exception, e:
		print(e)	
	finally:
		pass


def downImg1(src, path):
	f = src.split('/')[-1].split('?')[0]
	#print(f)
	fpath = path + f
	print(fpath)
	if f.find('.') < 1:
		return
	if os.path.exists(fpath):
		return
	try:
		r = requests.get(src)
		if r.status_code == 200:
			with open(fpath, 'wb') as code:
				code.write(r.content)
		else:
			print( "http error :" + src )
	except Exception, e:
		print(e)	
	finally:
		pass

	pass
